/**********************************************************************************************/
/* FBL_LogDebug.cpp                 	                                     				  */
/*                                                                       					  */
/* Copyright Paradigma, 1993-2006															  */
/* All Rights Reserved                                                   					  */
/**********************************************************************************************/

#include <VShared/FBL/publ/Headers/StdAfx.h>

#include <VShared/FBL/publ/Util_classes/FBL_String.h>
#include <VShared/FBL/publ/Utilities/FBL_Util_PathA.h>


/**********************************************************************************************/
#if __CHECK


/**********************************************************************************************/
FBL_Begin_Namespace

/**********************************************************************************************/
void LogAssert( 	
	const char* inFile, 
	const char* inFunc, 
	ulong 		inLine,
	const char* inMsg );


/**********************************************************************************************/
// Singleton of "FBL_Asserts.txt" assert log file.
// Is used by test system of Valentina.
//
I_LogFile* GetAssertsLog( void )
{
static I_LogFile_Ptr sLogFile = NULL;

	if( sLogFile == NULL )
	{
#if DEBUG_NEW == 2 
		StWatchLeakStopper stopper;
#endif // DEBUG_NEW

		sLogFile = CreateLogFile( "FBL_Asserts.txt" );

	}
	
	return sLogFile.get();
}


#pragma mark -

/**********************************************************************************************/
// Do log of some failed assert into log file.
//
void LogAssert( 	
	const char* inFile, 
	const char* inFunc, 
	ulong 		inLine,
	const char* inMsg )
{
	gAssertFailCount++;

	I_LogFile& log = *GetAssertsLog();
	
	if( log.get_VerboseLevel() == 0 )
		return;

	if( log.get_VerboseLevel() >= 1 )	// show all:
	{
		// Visual produce __FILE__ as ful path. We want extract only file name.
		inFile = ExtractNameFromFullPath( inFile );

		log << inFile << ":" << inFunc << ":" << (ulong) inLine << " " << inMsg << "\n";
	}
	
	//log.Flush();
}


FBL_End_Namespace


/**********************************************************************************************/
#endif // __CHECK
